package com.guaoran.spring.demo.controller;

import com.guaoran.spring.demo.bean.Demo;
import com.guaoran.spring.demo.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author : 孤傲然
 * @Description :
 * @date :2018/6/20 13:52
 */
@Controller
@RequestMapping("/demo")
public class DemoController {
    @Autowired
    private DemoService demoService;
    @RequestMapping("/query")
    public ModelAndView getDemoById(Long id){
        Demo demo = demoService.getDemoById(id);
        System.out.println(demo);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("demo",demo);
        modelAndView.setViewName("demo");
        return modelAndView;
    }

}
